function getAjaxObject() {
    ajaxObj = new XMLHttpRequest();
    return ajaxObj;
}
var ajax = getAjaxObject();

function doLogin() {
    var u;
    var p;
    var proto;
    
    u = document.getElementById('user').value;
    p = document.getElementById('pword').value;
    proto = document.getElementsByName('proto');
    
    for (i = 0; i < proto.length; i++) {
        if (proto[i].checked) {
            proto = proto[i].value;
            break;
        }
    }
    
    ajax.onreadystatechange = function() {
       if (ajax.readyState == 4) {
            var jsonResponse = ajax.responseText;           
       }
    };
    
    ajax.open('POST', 'incs/dispatch.php');
    ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajax.send('action=login&proto=' + proto + '&username=' + u + '&pass=' + p);    
}